package cn.itcast.tlias.com.tliaswork.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(urlPatterns = "/*")
public class MyFilter implements Filter {
    //只会被调用一次
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("拦截方法执行,拦截到请求.....");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }
    //只会被调用一次
    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
